package 动态规划专项训练.动态规划训练2;

/**300. 最长递增子序列
 * @author zx
 * @create 2022-04-08 12:04
 */
public class Num300 {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        if(n == 0){
            return 0;
        }
        int[] f = new int[n];
        int res = 0;
        for(int j = 0;j < n;j++){
            //case 1:
            f[j] = 1;
            //case 2:
            for(int i = 0;i < j;i++){
                if(nums[i] < nums[j] && f[i] + 1 > f[j]){
                    f[j] = f[i] + 1;
                }
            }
            res = Math.max(res,f[j]);
        }
        return res;
    }
}
